package com.haoniu.installment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haoniu.common.log.annotation.Log;
import com.haoniu.common.log.enums.BusinessType;
import com.haoniu.common.security.annotation.RequiresPermissions;
import com.haoniu.installment.domain.TJrRentInstallment;
import com.haoniu.installment.service.ITJrRentInstallmentService;
import com.haoniu.common.core.web.controller.BaseController;
import com.haoniu.common.core.web.domain.AjaxResult;
import com.haoniu.common.core.utils.poi.ExcelUtil;
import com.haoniu.common.core.web.page.TableDataInfo;

/**
 * 融资申请审核Controller
 * 
 * @author haoniu
 * @date 2022-07-25
 */
@RestController
@RequestMapping("/installment")
public class TJrRentInstallmentController extends BaseController
{
    @Autowired
    private ITJrRentInstallmentService tJrRentInstallmentService;

    /**
     * 查询融资申请审核列表
     */
    @RequiresPermissions("installment:installment:list")
    @GetMapping("/list")
    public TableDataInfo list(TJrRentInstallment tJrRentInstallment)
    {
        startPage();
        List<TJrRentInstallment> list = tJrRentInstallmentService.selectTJrRentInstallmentList(tJrRentInstallment);
        return getDataTable(list);
    }

    /**
     * 导出融资申请审核列表
     */
    @RequiresPermissions("installment:installment:export")
    @Log(title = "融资申请审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TJrRentInstallment tJrRentInstallment)
    {
        List<TJrRentInstallment> list = tJrRentInstallmentService.selectTJrRentInstallmentList(tJrRentInstallment);
        ExcelUtil<TJrRentInstallment> util = new ExcelUtil<TJrRentInstallment>(TJrRentInstallment.class);
        util.exportExcel(response, list, "融资申请审核数据");
    }

    /**
     * 获取融资申请审核详细信息
     */
    @RequiresPermissions("installment:installment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tJrRentInstallmentService.selectTJrRentInstallmentById(id));
    }

    /**
     * 新增融资申请审核
     */
    @RequiresPermissions("installment:installment:add")
    @Log(title = "融资申请审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TJrRentInstallment tJrRentInstallment)
    {
        return toAjax(tJrRentInstallmentService.insertTJrRentInstallment(tJrRentInstallment));
    }

    /**
     * 修改融资申请审核
     */
    @RequiresPermissions("installment:installment:edit")
    @Log(title = "融资申请审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TJrRentInstallment tJrRentInstallment)
    {
        return toAjax(tJrRentInstallmentService.updateTJrRentInstallment(tJrRentInstallment));
    }

    /**
     * 删除融资申请审核
     */
    @RequiresPermissions("installment:installment:remove")
    @Log(title = "融资申请审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tJrRentInstallmentService.deleteTJrRentInstallmentByIds(ids));
    }
}
